package cn.itcast.web.controller.dept;

import cn.itcast.domain.system.SysLog;
import cn.itcast.service.system.SysLogService;
import cn.itcast.web.controller.BaseController;
import com.github.pagehelper.PageInfo;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/system/log")
public class SysLogController extends BaseController {
    /**
     * 功能入口：aside.jsp
     * 方法参数：
     * 请求地址：log-list.jsp
     * 返回地址：system/log/log-list
     */
    String companyId="1";
@Autowired
private SysLogService sysLogService;

@RequiresPermissions("日志管理")
@RequestMapping("list")
    public String list(@RequestParam(defaultValue = "1") int pageNum,@RequestParam(defaultValue = "5") int pageSize){

    //需求：访问当前列表，要求登陆用户必须要有日志管理权限
    //1.获取当前用户
  //  Subject subject = SecurityUtils.getSubject();
  //  //2.权限校验代码，指定访问资源需要用户管理权限，自动校验（与用户拥有权限进行对比）
  //  subject.checkPermission("日志管理");
    PageInfo<SysLog> pageInfo = sysLogService.findPage(companyId, pageNum, pageSize);
    request.setAttribute("pageInfo",pageInfo);
        return "system/log/log-list";
    }
}
